package com.px.project.module.ml.controller;

import java.util.Date;
import java.util.List;

import org.apache.ibatis.annotations.Param;
import com.px.project.module.ml.service.IMlService;
import com.px.project.module.ml.vo.ml.MlCountVo;
import com.px.project.module.ml.vo.ml.MlInfoCountVo;
import com.px.project.module.ml.vo.ml.MlVerificationSheetCountVo;
import com.px.project.module.ml.vo.ml.MlWarningCountVo;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

/**
 * 物资系统》物资看板接口
 *
 * @author 品讯科技
 * @date 2024-08
 */
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping(value = "/ml")
public class MlController {
    private final IMlService mlService;

    /**
     * 获取仓库统计
     *
     * @return {@link MlCountVo}
     */
    @GetMapping(value = "/count/store")
    public MlCountVo count() {
        return this.mlService.listOfCount();
    }

    /**
     * 获取物资库存预警
     *
     * @param materialId 物料ID
     * @return {@link List}<{@link MlWarningCountVo}>
     */
    @GetMapping(value = "/count/material/{materialId}")
    public List<MlWarningCountVo> countOfWarning(@PathVariable("materialId") Long materialId) {
        return this.mlService.listOfCountAndWarning(materialId);
    }

    /**
     * 获取物资库存信息
     *
     * @param storeId 仓库ID
     * @param materialId 物料ID
     * @return {@link List}<{@link MlInfoCountVo}>
     */
    @GetMapping(value = "/count/info/{storeId}/{materialId}")
    public List<MlInfoCountVo> countOfInfo(@PathVariable("storeId") Long storeId, @PathVariable("materialId") Long materialId) {
        return this.mlService.listOfCountAndInfo(storeId, materialId);
    }

    /**
     * 获取物资核销信息
     *
     * @param materialId 物料ID
     * @return {@link List}<{@link MlVerificationSheetCountVo}>
     */
    @GetMapping(value = "/count/verification/sheet/{materialId}")
    public List<MlVerificationSheetCountVo> countOfInfo(@PathVariable("materialId") Long materialId, @Param("date") Date date) {
        return this.mlService.listOfCountAndVerificationSheet(materialId, date);
    }
}